package me.shan.bit;

/**
 * 描述：交换两个数，不使用中间变量
 *
 * @author liuchuang
 * @date 2021/6/14
 */
public class Swap {

    public static void main(String[] args) {
        int max = 100000000;
        int a = (int) (Math.random() * max);
        int b = (int) (Math.random() * max);
        System.out.println("a:" + a + ", b:" + b);
        a = a ^ b;
        b = a ^ b;
        a = a ^ b;
        System.out.println("a:" + a + ", b:" + b);
    }

}
